package com.rd.student.jiaji.class3.sunguowei.day0802.CountPractice;

import java.util.Arrays;

public class TestMaoPao {
    public static void main(String[] args) {
        int[] arr={60,77,33,55,11,22,80};
       //实现冒泡  从头开始遍历数组
        //遍历的是  相邻的元素
        int changeIndex = 0;
        int lastChangeIndex = arr.length - 1;
        for (int i = 0; i < arr.length-1; i++) {
            boolean isSorted=true;
            for (int j = 0; j < lastChangeIndex; j++) {
                if(arr[j]>arr[j+1]){
                    int tmp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=tmp;
                    System.out.println(Arrays.toString(arr));
                    isSorted=false;
                    changeIndex=j;
                }

            }
            lastChangeIndex=changeIndex;
            if(isSorted)break;
            System.out.println("-------------");
        }
    }
}
